<html>
    <head>
        <meta charset="utf-8"/>
        <meta name="viewport" content="width=device-width,user-scalable=no,initial-scale=1.0,maximum-scale=1.0"/>
        <!-- If you are using the CSS version, only link these 2 files, you may add app.css to use for your overrides if you like -->
        <link rel="stylesheet" href="amazeui/css/amazeui.min.css">
            <link rel="stylesheet" type="text/css" href="css/setting.css">
                <!-- If you are using the gem version, you need this only -->
    </head>
    <body>
        <div class="login_from">
            <from class="am-form">
                <fieldset>
                    <legend>vpn密码更改</legend>
                </fieldset>
                <div class="am-form-group">
                    <input type="text" id="oldPwd" placeholder="旧密码" value=""/>
                </div>
                <div class="am-form-group">
                    <input type="text" id="newPwd" placeholder="新密码" value=""/>
                </div>
                <div class="am-form-group">
                    <input type="password" id="newPwdCheck" placeholder="确认新密码" value=""/>
                </div>
                <div class="am-form-group">
                    <button type="button" class="am-btn am-btn-primary am-btn-block" onclick="saveButtonOnClick()">提交更改
                    </button>
                </div>
            </from>
            <div id='warningTip' class="am-alert am-alert-warning" data-am-alert style="display:none">
                <button type="button" class="am-close">&times;</button>
                <p>更改密码失败</p>
            </div>
        </div>
        
        <script src="amazeui/js/jquery.min.js"></script>
        <script src="amazeui/js/amazeui.min.js"></script>
        <script type="text/javascript" src="cordova.js"></script>
        <script src="js/setting.js"></script>
        <script>
            function saveButtonOnClick() {
                
                var networkState = navigator.connection.type;
                if (networkState == Connection.NONE || networkState == Connection.UNKNOWN) {
                    $('#warningTip p:first').text("网络断开,请检查网络");
                    $("#warningTip").show();
                    $('#warningTip').delay(6000).hide(0);
                } else {
                    $.AMUI.progress.start();
                    var oldPwd = $('#oldPwd').val();
                    var newPwd = $('#newPwd').val();
                    var newPwdCheck = $('#newPwdCheck').val();
                    if(newPwd==newPwdCheck){
                        setting.changePwd(oldPwd,newPwd);
                    }else{
                        $('#warningTip p:first').text("两次密码不一致");
                        $("#warningTip").show();
                        $('#warningTip').delay(6000).hide(0);
                    }

                }
            }
        </script>
    </body>
</html>